<template>
    <div id="page-box">
        <el-pagination
        :page-size="pageSize"
        :page-sizes="[10,20,30,40]"
        :current-page="currentPage"
        :total="pageTotal"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
    </div>
</template>
<script>
export default {
    name: 'vPagination',
    props: {
        pageSize: Number,
        currentPage: Number,
        pageTotal: Number
    },
    data () {
        return {
            pageCurrent: 1
        }
    },
    methods: {
        handleSizeChange (val) {
            let params = {
                pageSize: val,
                currentPage: this.currentPage
            }
            this.$emit('page-change', params)
        },
        handleCurrentChange (val) {
            if (val) {
                this.pageCurrent = val
            }
            let params = {
                pageSize: this.pageSize,
                currentPage: this.pageCurrent
            }
            this.$emit('page-change', params)
        }
    }
}
</script>
<style lang="stylus">
#page-box
    .el-pagination
        padding 10px 0
        background #fff
        border-top 1px solid #f0f0f0
</style>
